using ContactCenter.Core.DomainModel;
using FluentNHibernate.Mapping;

namespace ContactCenter.Persistence.NH.Mapping
{
    public sealed class CustomerMap : ClassMap<Customer>
    {
        public CustomerMap()
        {
            Table("CC_Customer");

            DynamicInsert();
            DynamicUpdate();

            Id(x => x.Id, "Id").GeneratedBy.HiLo("1000");
            Map(x => x.CustomerName);

            Component(x => x.ContactInfo).ColumnPrefix("Contact_");
            Component(x => x.CreditCard).ColumnPrefix("CCard_");
            HasMany(x => x.Addresses).KeyColumn("CustomerId")
                .Inverse()
                .Cascade.AllDeleteOrphan();
            Map(x => x.InsertDate);
        }
    }
}